#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__

#include "dev/DevInclude.h"
#include "game/GameLogic.h"
#include "game/PockerCard.h"
#include "game/HeadIcon.h"


#define MAX_CARDS                   20+1                                //20最大出的牌，1为不出
#define MAX_TIME                    30                                  //定时器最大时间30s

#define CARDS_SCALE                 0.7f
 
struct UserPoker
{
	int	iCardnum;
	BYTE bCardData[20];
};

struct LastPlayCardUser {
	int userid;
	CMD_C_OutCard outcard;
};


class DDZRoom:public TPanel
{
public:
    DDZRoom();
    CREATE_FUNC(DDZRoom);
    virtual  bool init();
    static  CCScene*  scene();
    virtual void procTuiEvent(const string&,TPanelItem*);
    virtual void updateGame(float dt);
    virtual void onCreateComplete();
    virtual void onEnter();
    virtual void onExit();
	DDZCGameLogicSingle gameLogic;
	
    
	 
	bool isPlaying;
	bool isReady;        //是否准备 
 
	BYTE selfOutCards[MAX_COUNT];          //自己出的牌
	BYTE otherOutCards[MAX_COUNT];         //别人出的牌
    
	  
    
	Byte rounds; 
	bool isGameOver;
    int outCardCount;
    
    
    
    
	vector<PockerCard *>cards;
	vector<PockerCard *>myCard;
	BYTE publiccard[GAME_PLAYER];			//底牌
	UserPoker userPoker[GAME_PLAYER];	//玩家牌
    UserPoker* myPocker;
    
    
	int currentPlayer; //当前玩家
    int lastOutCardPayer;
    int lastOutCount;
    
    
    int firstCallPos;
    int curCallPos;
    int curCallPoint;
    int hasCallNum;
    int bankerUser;
    
    void onCallPoint(int point);
    void showCall(int pos); 
    void robotcall(int pos,int score);
    void noticeOut(tagSearchCardResult& out);
    HeadIcon* getHeadIcon(int );
    
    PockerCard* getCardByNum(int);
    tagSearchCardResult searchResult;
    bool refreshSearchResult;
    int searchResultIdx;
    
    void clearSelectCard();
    void clearOutCard();
    bool checkOut(); 
    void onNextTurn();
    void onSelectEnd(CCObject*);
    
    TPanel* getCardPanel(int pos);
    TPanel* getOutCardPanel(int pos);
    
    void layoutAllCard();
    void gameEnd(); 
public: 
    void resetCard();
    void StartPlay();
    void onCardsShowed();
    void showCards();
    void showAllOutCards(int pos,BYTE * ,int count);
    void showOutCards(int pos,BYTE * ,int count);
    void showCard(int pos,bool isStart=false);
    void playGame(float dt);
    void onOutCardEnd(float dt);
    void onOtherCallPoint(float dt);
    int curRate;
    int winPlayer;
    int curPoint;
};

#endif // __HELLOWORLD_SCENE_H__
